package com.shushan.util;

/**
 * @ClassName: NumUtils
 * @Desciption: 数据工具类
 * @author: yichaohua
 * @date: 2018-02-02
 */
public class NumUtils {

    public static int statScore(int rightCount,int wrongCount){

        float score = rightCount * 100 / (rightCount + wrongCount);

        return (int)Math.floor(score);
    }

    public static String getAccuracy(int rightCount,int totalCount){
        if(rightCount < 0 || totalCount <= 0){
            return "0%";
        }

        return ((rightCount * 100) / totalCount) + "%";

    }

    public static int getScoreLevel(int score){
        int level;
        if(score < 60){
            level = 0;
        }else if(score < 70){
            level = 1;
        }else if(score < 80){
            level = 2;
        }else if(score < 90){
            level = 3;
        }else if(score < 100){
            level = 4;
        }else {
            level = 5;
        }

        return level;
    }
}
